home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / What's New / Development Kits / Mac_OS_USB_DDK_v1.2 / Examples / KeyboardModule / KeyboardModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  2.9 KB  |  101 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        KeyboardModule.h
  3.  
  4.     Contains:    Header file for Keyboard Module
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11. #ifndef __KeyboardModuleH__
  12. #define __KeyboardModuleH__
  13.  
  14. #include <Types.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <Processes.h>
  18. #include <USB.h>
  19.  
  20.  
  21. #define    kKeyboardModuleName    "\pUSBHIDKeyboardModule"
  22.  
  23. void     PostUSBKeyToMac(UInt16 rawUSBkey);
  24. void    PostADBKeyToMac(UInt16 virtualKeycode, UInt8 state);
  25.  
  26. void    USBDemoKeyIn(UInt32 refcon, void * theData);
  27. void    InitUSBKeyboard(void);
  28. void     KBDHIDNotification(UInt32 devicetype, UInt8 NewHIDData[], UInt8 OldHIDData[]);
  29.  
  30. Boolean    SetBit(UInt8 *bitmapArray, UInt16 index, Boolean value);
  31.  
  32. static     OSStatus    KeyboardModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  33. static     OSStatus    KeyboardInterfaceInitialize(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  34. static     OSStatus    KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
  35.  
  36. void     InitParamBlock(USBReference theInterfaceRef, USBPB * paramblock);
  37. void    KeyboardInitiateTransaction(USBPB *pb);
  38. void    KeyboardCompletionProc(USBPB *pb);
  39. void    InterfaceEntry(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBReference theInterfaceRef);
  40.  
  41. OSErr     FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc);
  42. void     NotifyRegisteredHIDUser(UInt32 devicetype, UInt8 hidReport[]);
  43.  
  44. #define kKeyboardRetryCount        3
  45. #define kKeyboardModifierBits    8
  46. #define kKeyboardReportKeys        6
  47. #define    kKeyboardOffsetToKeys    2
  48. #define kKeyboardReportSize        8
  49.  
  50. enum driverstages
  51. {
  52.     kUndefined = 0,
  53.     kSetKeyboardLEDs,
  54.     kSetProtocol,
  55.     kSetIdleRequest,
  56.     kConfigureInterface,
  57.     kFindPipe,
  58.     kReadInterruptPipe,
  59.     kClearFeature,
  60.     kReturnFromDriver =     0x1000,
  61.     kRetryTransaction =     0x2000,
  62.     kSyncTransaction =         0x4000,
  63.     kCompletionPending =     0x8000
  64. };
  65.  
  66. typedef struct
  67. {
  68.     USBPB                             pb;
  69.     void (*handler)(USBPB             *pb);
  70.  
  71.     USBReference                    interfaceRef;
  72.     USBPipeRef                        pipeRef;
  73.     
  74.     USBDeviceDescriptor             deviceDescriptor;
  75.     USBInterfaceDescriptor            interfaceDescriptor;
  76.  
  77.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;
  78.     USBEndPointDescriptorPtr        pEndpointDescriptor;
  79.     
  80.     UInt32                            hidDeviceType;
  81.     UInt8                            hidReport[8];
  82.     UInt8                            oldHIDReport[8];
  83.     UInt8                            padding[8];
  84.     
  85.     Boolean                            sendRawReportFlag;
  86.     Boolean                            hidEmulationInit;
  87.     Boolean                            keyboardReady;
  88.     Boolean                            intPipeAborted;
  89.     Boolean                            driverRemovalPending;
  90.     
  91.     HIDInterruptProcPtr             pSHIMInterruptRoutine;
  92.     HIDInterruptProcPtr             pSavedInterruptRoutine;
  93.     
  94.     UInt32                            interruptRefcon;
  95.     
  96.     SInt32                             retryCount;
  97.     SInt32                            delayLevel;
  98.     SInt32                            transDepth;
  99. } usbKeyboardPBStruct;
  100.  
  101. #endif //__KeyboardModuleH__